-
Notifications
You must be signed in to change notification settings - Fork 9
mctp-estack: Support vectored payloads in fragmenter #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it was on the todo list, good to avoid that buffer. fragment() can be replaced with a call to fragment_vectored() too.
mctp-estack/src/fragment.rs
Outdated
| let remaining_payload_len = total_payload_len - self.payload_used; | ||
| let l = remaining_payload_len.min(rest.len()); | ||
| let (d, rest) = rest.split_at_mut(l); | ||
| crate::util::copy_vectored(payload, self.payload_used, d); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be a lot of conversion back and forth between total length/offset and slice indices/offsets.
It might simplify the code to remove total_payload_len and payload_used, and instead store current input slice index and offset in Fragmenter? get_sub_slice() wouldn't be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was thinking something similar while implementing, but just continued bending the existing code until it worked to get a poc.
A "VectorReader" that holds the state and has all of the clean methods like read(), is_at_end(), ... could be nice.
I'll try to come up with something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked out as I intended.
I'm happy how the Fragmenter looks now.
Maybe there are some nits how to make the reader implementation a bit cleaner, but finding the best way is hard with all the available stuff to access slices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that looks good.
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
|
Noticed, that my code was missing the check for All the tests seem to just check with |
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
55294db to
793949a
Compare
Yes, the better code coverage would certainly be worth adding. For checking locally I've been using In this specific case I think it'd be difficult to notice that no tests match on |
Add a method to fragment vectored payloads directly.
This eliminates the need to copy vectored payloads to a buffer that can hold the largest possible payload and instead copies the data directly to the packet buffer while fragmenting.